home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / StandardFile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  11.6 KB  |  338 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        StandardFile.h
  3.  
  4.      Contains:    Standard File package Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1990-1995, 1997-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __STANDARDFILE__
  18. #define __STANDARDFILE__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __DIALOGS__
  24. #include <Dialogs.h>
  25. #endif
  26. #ifndef __FILES__
  27. #include <Files.h>
  28. #endif
  29.  
  30.  
  31.  
  32. #if PRAGMA_ONCE
  33. #pragma once
  34. #endif
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_IMPORT
  41. #pragma import on
  42. #endif
  43.  
  44. #if PRAGMA_STRUCT_ALIGN
  45.     #pragma options align=mac68k
  46. #elif PRAGMA_STRUCT_PACKPUSH
  47.     #pragma pack(push, 2)
  48. #elif PRAGMA_STRUCT_PACK
  49.     #pragma pack(2)
  50. #endif
  51.  
  52.  
  53. enum {
  54.                                                                 /* resource IDs of pre-7.0 get and put dialogs */
  55.     putDlgID                    = -3999,
  56.     getDlgID                    = -4000
  57. };
  58.  
  59.  
  60. enum {
  61.                                                                 /* item offsets of pre-7.0 get and put dialogs */
  62.     putSave                        = 1,
  63.     putCancel                    = 2,
  64.     putEject                    = 5,
  65.     putDrive                    = 6,
  66.     putName                        = 7,
  67.     getOpen                        = 1,
  68.     getCancel                    = 3,
  69.     getEject                    = 5,
  70.     getDrive                    = 6,
  71.     getNmList                    = 7,
  72.     getScroll                    = 8
  73. };
  74.  
  75.  
  76. enum {
  77.                                                                 /* resource IDs of 7.0 get and put dialogs */
  78.     sfPutDialogID                = -6043,
  79.     sfGetDialogID                = -6042
  80. };
  81.  
  82.  
  83. enum {
  84.                                                                 /* item offsets of 7.0 get and put dialogs */
  85.     sfItemOpenButton            = 1,
  86.     sfItemCancelButton            = 2,
  87.     sfItemBalloonHelp            = 3,
  88.     sfItemVolumeUser            = 4,
  89.     sfItemEjectButton            = 5,
  90.     sfItemDesktopButton            = 6,
  91.     sfItemFileListUser            = 7,
  92.     sfItemPopUpMenuUser            = 8,
  93.     sfItemDividerLinePict        = 9,
  94.     sfItemFileNameTextEdit        = 10,
  95.     sfItemPromptStaticText        = 11,
  96.     sfItemNewFolderUser            = 12
  97. };
  98.  
  99.  
  100. enum {
  101.                                                                 /* pseudo-item hits for use in DlgHook */
  102.     sfHookFirstCall                = -1,
  103.     sfHookCharOffset            = 0x1000,
  104.     sfHookNullEvent                = 100,
  105.     sfHookRebuildList            = 101,
  106.     sfHookFolderPopUp            = 102,
  107.     sfHookOpenFolder            = 103,                            /* the following are only in system 7.0+ */
  108.     sfHookLastCall                = -2,
  109.     sfHookOpenAlias                = 104,
  110.     sfHookGoToDesktop            = 105,
  111.     sfHookGoToAliasTarget        = 106,
  112.     sfHookGoToParent            = 107,
  113.     sfHookGoToNextDrive            = 108,
  114.     sfHookGoToPrevDrive            = 109,
  115.     sfHookChangeSelection        = 110,
  116.     sfHookSetActiveOffset        = 200
  117. };
  118.  
  119.  
  120. /* the refcon field of the dialog record during a
  121.  modalfilter or dialoghook contains one of the following */
  122.  
  123. enum {
  124.     sfMainDialogRefCon            = FOUR_CHAR_CODE('stdf'),
  125.     sfNewFolderDialogRefCon        = FOUR_CHAR_CODE('nfdr'),
  126.     sfReplaceDialogRefCon        = FOUR_CHAR_CODE('rplc'),
  127.     sfStatWarnDialogRefCon        = FOUR_CHAR_CODE('stat'),
  128.     sfLockWarnDialogRefCon        = FOUR_CHAR_CODE('lock'),
  129.     sfErrorDialogRefCon            = FOUR_CHAR_CODE('err ')
  130. };
  131.  
  132.  
  133.  
  134. struct SFReply {
  135.     Boolean                         good;
  136.     Boolean                         copy;
  137.     OSType                             fType;
  138.     short                             vRefNum;
  139.     short                             version;
  140.     StrFileName                     fName;                        /* a Str63 on MacOS */
  141. };
  142. typedef struct SFReply                    SFReply;
  143.  
  144. struct StandardFileReply {
  145.     Boolean                         sfGood;
  146.     Boolean                         sfReplacing;
  147.     OSType                             sfType;
  148.     FSSpec                             sfFile;
  149.     ScriptCode                         sfScript;
  150.     short                             sfFlags;
  151.     Boolean                         sfIsFolder;
  152.     Boolean                         sfIsVolume;
  153.     long                             sfReserved1;
  154.     short                             sfReserved2;
  155. };
  156. typedef struct StandardFileReply        StandardFileReply;
  157. /* for CustomXXXFile, ActivationOrderListPtr parameter is a pointer to an array of item numbers */
  158.  
  159. typedef const short *                    ActivationOrderListPtr;
  160. typedef CALLBACK_API( short , DlgHookProcPtr )(short item, DialogPtr theDialog);
  161. typedef CALLBACK_API( Boolean , FileFilterProcPtr )(CInfoPBPtr pb);
  162. /* the following also include an extra parameter of "your data pointer" */
  163. typedef CALLBACK_API( short , DlgHookYDProcPtr )(short item, DialogPtr theDialog, void *yourDataPtr);
  164. typedef CALLBACK_API( Boolean , ModalFilterYDProcPtr )(DialogPtr theDialog, EventRecord *theEvent, short *itemHit, void *yourDataPtr);
  165. typedef CALLBACK_API( Boolean , FileFilterYDProcPtr )(CInfoPBPtr pb, void *yourDataPtr);
  166. typedef CALLBACK_API( void , ActivateYDProcPtr )(DialogPtr theDialog, short itemNo, Boolean activating, void *yourDataPtr);
  167. typedef STACK_UPP_TYPE(DlgHookProcPtr)                             DlgHookUPP;
  168. typedef STACK_UPP_TYPE(FileFilterProcPtr)                         FileFilterUPP;
  169. typedef STACK_UPP_TYPE(DlgHookYDProcPtr)                         DlgHookYDUPP;
  170. typedef STACK_UPP_TYPE(ModalFilterYDProcPtr)                     ModalFilterYDUPP;
  171. typedef STACK_UPP_TYPE(FileFilterYDProcPtr)                     FileFilterYDUPP;
  172. typedef STACK_UPP_TYPE(ActivateYDProcPtr)                         ActivateYDUPP;
  173. enum { uppDlgHookProcInfo = 0x000003A0 };                         /* pascal 2_bytes Func(2_bytes, 4_bytes) */
  174. enum { uppFileFilterProcInfo = 0x000000D0 };                     /* pascal 1_byte Func(4_bytes) */
  175. enum { uppDlgHookYDProcInfo = 0x00000FA0 };                     /* pascal 2_bytes Func(2_bytes, 4_bytes, 4_bytes) */
  176. enum { uppModalFilterYDProcInfo = 0x00003FD0 };                 /* pascal 1_byte Func(4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  177. enum { uppFileFilterYDProcInfo = 0x000003D0 };                     /* pascal 1_byte Func(4_bytes, 4_bytes) */
  178. enum { uppActivateYDProcInfo = 0x000036C0 };                     /* pascal no_return_value Func(4_bytes, 2_bytes, 1_byte, 4_bytes) */
  179. #define NewDlgHookProc(userRoutine)                             (DlgHookUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDlgHookProcInfo, GetCurrentArchitecture())
  180. #define NewFileFilterProc(userRoutine)                             (FileFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileFilterProcInfo, GetCurrentArchitecture())
  181. #define NewDlgHookYDProc(userRoutine)                             (DlgHookYDUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDlgHookYDProcInfo, GetCurrentArchitecture())
  182. #define NewModalFilterYDProc(userRoutine)                         (ModalFilterYDUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppModalFilterYDProcInfo, GetCurrentArchitecture())
  183. #define NewFileFilterYDProc(userRoutine)                         (FileFilterYDUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileFilterYDProcInfo, GetCurrentArchitecture())
  184. #define NewActivateYDProc(userRoutine)                             (ActivateYDUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppActivateYDProcInfo, GetCurrentArchitecture())
  185. #define CallDlgHookProc(userRoutine, item, theDialog)             CALL_TWO_PARAMETER_UPP((userRoutine), uppDlgHookProcInfo, (item), (theDialog))
  186. #define CallFileFilterProc(userRoutine, pb)                     CALL_ONE_PARAMETER_UPP((userRoutine), uppFileFilterProcInfo, (pb))
  187. #define CallDlgHookYDProc(userRoutine, item, theDialog, yourDataPtr)  CALL_THREE_PARAMETER_UPP((userRoutine), uppDlgHookYDProcInfo, (item), (theDialog), (yourDataPtr))
  188. #define CallModalFilterYDProc(userRoutine, theDialog, theEvent, itemHit, yourDataPtr)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppModalFilterYDProcInfo, (theDialog), (theEvent), (itemHit), (yourDataPtr))
  189. #define CallFileFilterYDProc(userRoutine, pb, yourDataPtr)         CALL_TWO_PARAMETER_UPP((userRoutine), uppFileFilterYDProcInfo, (pb), (yourDataPtr))
  190. #define CallActivateYDProc(userRoutine, theDialog, itemNo, activating, yourDataPtr)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppActivateYDProcInfo, (theDialog), (itemNo), (activating), (yourDataPtr))
  191. typedef OSType                             SFTypeList[4];
  192. /*
  193.     The GetFile "typeList" parameter type has changed from "SFTypeList" to "ConstSFTypeListPtr".
  194.     For C, this will add "const" and make it an in-only parameter.
  195.     For Pascal, this will require client code to use the @ operator, but make it easier to specify long lists.
  196.  
  197.     ConstSFTypeListPtr is a pointer to an array of OSTypes.
  198. */
  199. typedef const OSType *                    ConstSFTypeListPtr;
  200. EXTERN_API( void )
  201. SFPutFile                        (Point                     where,
  202.                                  ConstStr255Param         prompt,
  203.                                  ConstStr255Param         origName,
  204.                                  DlgHookUPP             dlgHook, /* can be NULL */
  205.                                  SFReply *                reply)                                THREEWORDINLINE(0x3F3C, 0x0001, 0xA9EA);
  206.  
  207. EXTERN_API( void )
  208. SFGetFile                        (Point                     where,
  209.                                  ConstStr255Param         prompt,
  210.                                  FileFilterUPP             fileFilter, /* can be NULL */
  211.                                  short                     numTypes,
  212.                                  ConstSFTypeListPtr     typeList, /* can be NULL */
  213.                                  DlgHookUPP             dlgHook, /* can be NULL */
  214.                                  SFReply *                reply)                                THREEWORDINLINE(0x3F3C, 0x0002, 0xA9EA);
  215.  
  216. EXTERN_API( void )
  217. SFPPutFile                        (Point                     where,
  218.                                  ConstStr255Param         prompt,
  219.                                  ConstStr255Param         origName,
  220.                                  DlgHookUPP             dlgHook,
  221.                                  SFReply *                reply,
  222.                                  short                     dlgID,
  223.                                  ModalFilterUPP         filterProc) /* can be NULL */        THREEWORDINLINE(0x3F3C, 0x0003, 0xA9EA);
  224.  
  225. EXTERN_API( void )
  226. SFPGetFile                        (Point                     where,
  227.                                  ConstStr255Param         prompt,
  228.                                  FileFilterUPP             fileFilter, /* can be NULL */
  229.                                  short                     numTypes,
  230.                                  ConstSFTypeListPtr     typeList, /* can be NULL */
  231.                                  DlgHookUPP             dlgHook, /* can be NULL */
  232.                                  SFReply *                reply,
  233.                                  short                     dlgID,
  234.                                  ModalFilterUPP         filterProc) /* can be NULL */        THREEWORDINLINE(0x3F3C, 0x0004, 0xA9EA);
  235.  
  236. EXTERN_API( void )
  237. StandardPutFile                    (ConstStr255Param         prompt,
  238.                                  ConstStr255Param         defaultName,
  239.                                  StandardFileReply *    reply)                                THREEWORDINLINE(0x3F3C, 0x0005, 0xA9EA);
  240.  
  241. EXTERN_API( void )
  242. StandardGetFile                    (FileFilterUPP             fileFilter, /* can be NULL */
  243.                                  short                     numTypes,
  244.                                  ConstSFTypeListPtr     typeList, /* can be NULL */
  245.                                  StandardFileReply *    reply)                                THREEWORDINLINE(0x3F3C, 0x0006, 0xA9EA);
  246.  
  247. EXTERN_API( void )
  248. CustomPutFile                    (ConstStr255Param         prompt,
  249.                                  ConstStr255Param         defaultName,
  250.                                  StandardFileReply *    reply,
  251.                                  short                     dlgID,
  252.                                  Point                     where,
  253.                                  DlgHookYDUPP             dlgHook, /* can be NULL */
  254.                                  ModalFilterYDUPP         filterProc, /* can be NULL */
  255.                                  ActivationOrderListPtr  activeList, /* can be NULL */
  256.                                  ActivateYDUPP             activate,
  257.                                  void *                    yourDataPtr)                        THREEWORDINLINE(0x3F3C, 0x0007, 0xA9EA);
  258.  
  259. EXTERN_API( void )
  260. CustomGetFile                    (FileFilterYDUPP         fileFilter, /* can be NULL */
  261.                                  short                     numTypes,
  262.                                  ConstSFTypeListPtr     typeList, /* can be NULL */
  263.                                  StandardFileReply *    reply,
  264.                                  short                     dlgID,
  265.                                  Point                     where,
  266.                                  DlgHookYDUPP             dlgHook, /* can be NULL */
  267.                                  ModalFilterYDUPP         filterProc, /* can be NULL */
  268.                                  ActivationOrderListPtr  activeList,
  269.                                  ActivateYDUPP             activate, /* can be NULL */
  270.                                  void *                    yourDataPtr)                        THREEWORDINLINE(0x3F3C, 0x0008, 0xA9EA);
  271.  
  272. EXTERN_API( OSErr )
  273. StandardOpenDialog                (StandardFileReply *    reply);
  274.  
  275. #if CGLUESUPPORTED
  276. EXTERN_API_C( void )
  277. sfpputfile                        (Point *                where,
  278.                                  const char *            prompt,
  279.                                  const char *            origName,
  280.                                  DlgHookUPP             dlgHook, /* can be NULL */
  281.                                  SFReply *                reply,
  282.                                  short                     dlgID,
  283.                                  ModalFilterUPP         filterProc) /* can be NULL */;
  284.  
  285. EXTERN_API_C( void )
  286. sfgetfile                        (Point *                where,
  287.                                  const char *            prompt,
  288.                                  FileFilterUPP             fileFilter, /* can be NULL */
  289.                                  short                     numTypes,
  290.                                  ConstSFTypeListPtr     typeList, /* can be NULL */
  291.                                  DlgHookUPP             dlgHook, /* can be NULL */
  292.                                  SFReply *                reply);
  293.  
  294. EXTERN_API_C( void )
  295. sfpgetfile                        (Point *                where,
  296.                                  const char *            prompt,
  297.                                  FileFilterUPP             fileFilter, /* can be NULL */
  298.                                  short                     numTypes,
  299.                                  ConstSFTypeListPtr     typeList, /* can be NULL */
  300.                                  DlgHookUPP             dlgHook, /* can be NULL */
  301.                                  SFReply *                reply,
  302.                                  short                     dlgID,
  303.                                  ModalFilterUPP         filterProc) /* can be NULL */;
  304.  
  305. EXTERN_API_C( void )
  306. sfputfile                        (Point *                where,
  307.                                  const char *            prompt,
  308.                                  const char *            origName,
  309.                                  DlgHookUPP             dlgHook, /* can be NULL */
  310.                                  SFReply *                reply);
  311.  
  312. #endif  /* CGLUESUPPORTED */
  313.  
  314.  
  315.  
  316.  
  317.  
  318. #if PRAGMA_STRUCT_ALIGN
  319.     #pragma options align=reset
  320. #elif PRAGMA_STRUCT_PACKPUSH
  321.     #pragma pack(pop)
  322. #elif PRAGMA_STRUCT_PACK
  323.     #pragma pack()
  324. #endif
  325.  
  326. #ifdef PRAGMA_IMPORT_OFF
  327. #pragma import off
  328. #elif PRAGMA_IMPORT
  329. #pragma import reset
  330. #endif
  331.  
  332. #ifdef __cplusplus
  333. }
  334. #endif
  335.  
  336. #endif /* __STANDARDFILE__ */
  337.  
  338.